<?php

namespace Alipay\AlipayFund\Response;

use Alipay\Http\Response;

class AlipayFundTransUniTransferResponse extends Response
{
    private $msg;

    private $outBizNo;

    private $orderId;

    private $payFundOrderId;

    private $status;

    private $sign;

    public function resolve(): Response
    {
        parent::resolve();
        if (json_decode($this->getBody())) {
            $body = json_decode($this->getBody(), true);

            $this->setBody($body);
            $this->sign = $body['sign'] ?? '';
            $body = $body['alipay_fund_trans_uni_transfer_response'] ?? '';

            $this->outBizNo = $body['out_biz_no'] ?? '';
            $this->orderId = $body['order_id'] ?? '';
            $this->payFundOrderId = $body['pay_fund_order_id'] ?? '';

            $this->msg = $body['msg'] ?? '';
            $this->status = $body['status'] ?? '';

            $code = $body['code'] ?? '';
            if ($code != '10000') {
                $this->setError($this->msg . ($body['sub_code'] ?? '') . ($body['sub_msg'] ?? ''));
            }
        } else {
            $this->setError($this->getBody());
        }
        return $this;
    }

    /**
     * @return mixed
     */
    public function getMsg()
    {
        return $this->msg;
    }

    /**
     * @return mixed
     */
    public function getOutBizNo()
    {
        return $this->outBizNo;
    }

    /**
     * @return mixed
     */
    public function getOrderId()
    {
        return $this->orderId;
    }

    /**
     * @return mixed
     */
    public function getPayFundOrderId()
    {
        return $this->payFundOrderId;
    }
}